# -*- coding: utf-8 -*-
"""
Created on Sat Jan 18 23:58:43 2020

@author: ikaros
"""

import numpy as np
import os #路径有中文时可能会报一些奇怪的错

o_label_dir = './o_label/'                          #原始标签地址
save_label_dir = './d_label/'                       #新标签保存地址

label_names = np.array(os.listdir(o_label_dir))     #获取所有标签文件名
for label in label_names:
    if label is None:                               #避免内容为空
        continue
    new_lines = []
    labelname = o_label_dir + label         
    with open(labelname, "r") as f1:                #读取标签文件的坐标和标签
        lines = f1.readlines()
    for line in lines:
        new_line = line.replace('\n',',A') + '\n'   #给每行加上一个A作为正样本的标志
        new_lines.append(new_line)
    print('new_lines:',new_lines)
    new_label = save_label_dir + 'gt_' + label      #修改保存的绝对路径
    with open(new_label, "a") as f2:                #写入txt文件
        for ns in new_lines:
            f2.write(ns)
    
    
























